package com.allenkerr.cloud.user.controller;

import com.allenkerr.cloud.user.entity.User;
import com.allenkerr.cloud.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by 小柯(Allen Kerr) on 17.6.13 15:00.
 */
@RestController // 等于 @ResponseBody + @Controller
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 查找所有用户信息
     */
    @GetMapping("/users")
    public List<User> findAll() {
        return userService.findAll();
    }

    /**
     * 根据Id查找用户信息
     */
    @GetMapping("/users/{id}")
    public User findById(@PathVariable Long id) {
        return userService.findById(id);
    }

}
